package com.zgkxzx.videoprocessdemo

import android.content.Intent
import android.os.Bundle
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.zgkxzx.vediotest.page.ClipActivity
import com.zgkxzx.vediotest.page.CutActivity
import com.zgkxzx.vediotest.utils.Constants
import com.zgkxzx.videoprocessdemo.utils.FileUtil

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            rootView()
        }
    }

    @Composable
    private fun rootView() {
        Column {
            Text(
                text = "视频处理功能调试项",
                fontSize = 20.sp,
                textAlign = TextAlign.Center,
                modifier = Modifier
                    .padding(20.dp)
                    .fillMaxWidth()
            )

            button("拷贝测试资源") {
                copyAssertTestVideoFile()
            }
            button("时间裁剪") {
                startActivity(Intent(this@MainActivity, CutActivity::class.java))
            }
            button("画幅裁剪") {
                startActivity(Intent(this@MainActivity, ClipActivity::class.java))
            }

        }
    }

    private fun copyAssertTestVideoFile() {
        val targetPath = Constants.getTestPath(this)
        FileUtil.copy(this, Constants.VIDEO_NAME, targetPath, Constants.VIDEO_NAME)
        Toast.makeText(this,"拷贝成功 $targetPath", Toast.LENGTH_LONG).show()
    }

    @Composable
    private fun button(text: String, click: () -> Unit) = Button(
        onClick = click, modifier = Modifier
            .padding(10.dp)
            .fillMaxWidth()
    ) {
        Text(text = text)
    }

    companion object {
        const val TAG = "MainActivity"
    }
}
